package ooday01;

//学生类
public class Student {
    //成员变量
    Student(){ //构造方法重载

    }


        String name;//紫色为全局变量/成员变量
        int age;
        String className;
        String stuId;

    void study() {
        System.out.println(this.name + "在学习..........");//访问成员变量前有this。
    }

    void sayHi() {
        System.out.println("大家好！我叫" + this.name + "今年" + this.age + "岁了,所在班级为" + this.className +
                "学号为：" + this.stuId);

    }

    void playWith(String anotherName) { System.out.println(this.name + "正在和" + anotherName + "一起玩......"); }


//构造方法
    Student(String name,int age,String className,String stuId){
        this.name=name;//黑色为局部变量
        this.age=age;
        this.className=className;
        this.stuId=stuId;
    }
    Student(String name,int age){    //
        this.name = name;
        this.age = age;
    }
}
